# -*- coding: utf-8 -*-
import time
from Page.informaintenancePage import informaintenancePage
from Page.noscanningPage import noscanningPage
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
class informaintenance():
    def __init__(self,driver):
        self.driver=driver
        self.informaintenancePage = informaintenancePage(self.driver)
        self.noscanningPage = noscanningPage(self.driver)
    # 无扫描计划信息维护
    def informaintenance(self,PlanDesc,MinAge,MaxAge,AvgAge,NumPeople,MinSalary,MaxSalary,AvgSalary,OtherDesc,
                         OccupCode,OccupMidTypeCode,OccupType):
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        self.informaintenancePage.inpPlanDesc().send_keys(PlanDesc)
        time.sleep(1)
        # 职业类别
        ActionChains(self.driver).double_click(self.informaintenancePage.secOccupType()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(OccupType)
        time.sleep(1)
        # self.informaintenancePage.secOccupType().send_keys(OccupType)
        # time.sleep(1)
        # self.informaintenancePage.secOccupName().send_keys(OccupName)
        # time.sleep(1)
        # 职业中分类
        ActionChains(self.driver).double_click(self.informaintenancePage.secOccupMidType()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(OccupMidTypeCode)
        time.sleep(1)
        # self.informaintenancePage.secOccupMidType().send_keys(OccupMidTypeCode)
        # self.informaintenancePage.secOccupMidName().send_keys(OccupMidName)
        # time.sleep(1)
        # 工种
        ActionChains(self.driver).double_click(self.informaintenancePage.secOccupCode()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(OccupCode)
        time.sleep(1)
        # self.informaintenancePage.secOccupCode().send_keys(OccupCode)
        # self.informaintenancePage.secOccupCodeName().send_keys(OccupCodeName)
        # time.sleep(1)
        self.informaintenancePage.inpMinAge().send_keys(MinAge)
        time.sleep(1)
        self.informaintenancePage.inpMaxAge().send_keys(MaxAge)
        time.sleep(1)
        self.informaintenancePage.inpAvgAge().send_keys(AvgAge)
        time.sleep(1)
        self.informaintenancePage.inpNumPeople().send_keys(NumPeople)
        time.sleep(1)
        self.informaintenancePage.inpMinSalary().send_keys(MinSalary)
        time.sleep(1)
        self.informaintenancePage.inpMaxSalary().send_keys(MaxSalary)
        time.sleep(1)
        self.informaintenancePage.inpAvgSalary().send_keys(AvgSalary)
        time.sleep(1)
        self.informaintenancePage.inpOtherDesc().send_keys(OtherDesc)
        time.sleep(1)
        self.informaintenancePage.cheMyself().click()
        time.sleep(1)
        self.informaintenancePage.butAddPlan().click()
        time.sleep(1)
        windows =self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
    # 询价计划信息维护
    def informaintenance1(self,PlanDesc,MinAge,MaxAge,AvgAge,NumPeople,MinSalary,MaxSalary,AvgSalary,OtherDesc,
                         OccupCode,OccupMidTypeCode,OccupType,SocialInsuRate,MaleRate,FemaleRate):
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        self.informaintenancePage.inpPlanDesc().send_keys(PlanDesc)
        time.sleep(1)
        # 职业类别
        ActionChains(self.driver).double_click(self.informaintenancePage.secOccupType()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(OccupType)
        time.sleep(1)

        ActionChains(self.driver).double_click(self.informaintenancePage.secOccupMidType()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(OccupMidTypeCode)
        time.sleep(1)

        # 工种
        ActionChains(self.driver).double_click(self.informaintenancePage.secOccupCode()).perform()
        time.sleep(1)
        Select(self.noscanningPage.codeselect()).select_by_visible_text(OccupCode)
        time.sleep(1)

        self.informaintenancePage.inpMinAge().send_keys(MinAge)
        time.sleep(1)
        self.informaintenancePage.inpMaxAge().send_keys(MaxAge)
        time.sleep(1)
        self.informaintenancePage.inpAvgAge().send_keys(AvgAge)
        time.sleep(1)
        self.informaintenancePage.inpNumPeople().send_keys(NumPeople)
        time.sleep(1)
        self.informaintenancePage.inpMinSalary().send_keys(MinSalary)
        time.sleep(1)
        self.informaintenancePage.inpMaxSalary().send_keys(MaxSalary)
        time.sleep(1)
        self.informaintenancePage.inpAvgSalary().send_keys(AvgSalary)
        time.sleep(1)
        self.informaintenancePage.inpSocialInsuRate().send_keys(SocialInsuRate)
        time.sleep(1)
        self.informaintenancePage.inpMaleRate().send_keys(MaleRate)
        time.sleep(1)
        self.informaintenancePage.inpFemaleRate().send_keys(FemaleRate)
        time.sleep(1)
        self.informaintenancePage.inpOtherDesc().send_keys(OtherDesc)
        time.sleep(1)
        self.informaintenancePage.cheMyself().click()
        time.sleep(1)
        self.informaintenancePage.btnAddPlan1().click()
        time.sleep(1)
        windows =self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)

    def planDetailOpen(self):
        windows_1 = self.driver.window_handles
        self.driver.switch_to.window(windows_1[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)
        # 点击计划信息维护
        self.informaintenancePage.butplanDetailOpen().click()
        time.sleep(1)
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)
    def informationDetail(self,FixedAmnt,ExceptPrem,Remark,PlanCode,DutyCode,RiskCode,AmntType,ExceptPremType):
        # 计划编码
        ActionChains(self.driver).double_click(self.informaintenancePage.secPlanCode()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(PlanCode)
        time.sleep(1)
        # 险种
        ActionChains(self.driver).double_click(self.informaintenancePage.secRiskCode()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(RiskCode)
        time.sleep(1)
        # 责任
        ActionChains(self.driver).double_click(self.informaintenancePage.secDutyCode()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(DutyCode)
        time.sleep(1)
        '''
        # 免赔额
        self.informaintenancePage.inpFranchise().send_keys(Franchise)
        time.sleep(1)
        # 赔付比例
        self.informaintenancePage.inpRatePay().send_keys(RatePay)
        time.sleep(1)
        '''
        # 保额类型
        ActionChains(self.driver).double_click(self.informaintenancePage.secAmntType()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(AmntType)
        time.sleep(1)
        self.informaintenancePage.inpFixedAmnt().send_keys(FixedAmnt)
        time.sleep(1)
        ActionChains(self.driver).double_click(self.informaintenancePage.secExceptPremType()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(ExceptPremType)
        time.sleep(1)
        self.informaintenancePage.inpExceptPrem().send_keys(ExceptPrem)
        time.sleep(1)
        self.informaintenancePage.inpRemark().send_keys(Remark)
        time.sleep(1)
        self.informaintenancePage.butAddNew().click()
        time.sleep(1)
        window1 = self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        windows2 = self.driver.window_handles
        self.driver.switch_to.window(windows2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)
        '''
        询价
        '''
    def informationDetail1(self,FixedAmnt,ExceptPrem,Remark,PlanCode,DutyCode,RiskCode,AmntType,ExceptPremType):
        # 计划编码
        ActionChains(self.driver).double_click(self.informaintenancePage.secPlanCode()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(PlanCode)
        time.sleep(1)
        # 险种
        ActionChains(self.driver).double_click(self.informaintenancePage.secRiskCode()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(RiskCode)
        time.sleep(1)
        # 责任
        ActionChains(self.driver).double_click(self.informaintenancePage.secDutyCode()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(DutyCode)
        time.sleep(1)
        '''
        # 免赔额
        self.informaintenancePage.inpFranchise().send_keys(Franchise)
        time.sleep(1)
        # 赔付比例
        self.informaintenancePage.inpRatePay().send_keys(RatePay)
        time.sleep(1)
        '''
        # 保额类型
        ActionChains(self.driver).double_click(self.informaintenancePage.secAmntType()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(AmntType)
        time.sleep(1)
        self.informaintenancePage.inpFixedAmnt().send_keys(FixedAmnt)
        time.sleep(1)
        ActionChains(self.driver).double_click(self.informaintenancePage.secExceptPremType()).perform()
        time.sleep(1)
        Select(self.informaintenancePage.secCodeSelect1()).select_by_visible_text(ExceptPremType)
        time.sleep(1)
        self.informaintenancePage.inpExceptPrem().send_keys(ExceptPrem)
        time.sleep(1)
        self.informaintenancePage.inpRemark().send_keys(Remark)
        time.sleep(1)
        self.informaintenancePage.btnADDNew1().click()
        time.sleep(1)
        window1 = self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        windows2 = self.driver.window_handles
        self.driver.switch_to.window(windows2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)

    def inforDetailOver(self):
        # windows2 = self.driver.window_handles
        # self.driver.switch_to.window(windows2[-1])
        # self.driver.switch_to.default_content()
        # self.driver.switch_to.frame("fraInterface")
        # time.sleep(2)
        self.informaintenancePage.butClose().click()
        time.sleep(1)
        windows3 = self.driver.window_handles
        self.driver.switch_to.window(windows3[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        self.informaintenancePage.butOver().click()
        time.sleep(1)
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)












